package com.wuba.rxjavademo.lyz.day0429;

import java.util.concurrent.TimeUnit;

import rx.Observable;

/**
 * Created by liyaxing on 2016/5/4.
 */
public class Demo02 {

    public static void main(String[] ss){

        Demo02 demo = new Demo02() ;
        Observable<Long> observable = demo.createObservate() ;
        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        observable.subscribe(aLong -> print("--1--" + aLong)) ;
        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        //observable.subscribe(aLong -> print("--2--" + aLong)) ;
        //try {
        //    Thread.sleep(5000);
        //} catch (InterruptedException e) {
        //    e.printStackTrace();
        //}
    }


    private Observable<Long> createObservate(){
        return Observable.interval(1, TimeUnit.SECONDS) ;
    }

    private static void print(Object obj){
        System.out.println(obj) ;
    }
}
